package com;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.connection.jdbconnection;

public class CreateAccount extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		String U_id = request.getParameter("Uid");
		String Password = request.getParameter("pass");
		String F_name = request.getParameter("Fname");
		String L_name = request.getParameter("Lname");
		String Email = request.getParameter("Eid");

		jdbconnection db = new jdbconnection();
		Statement statement = db.jdbConnection();
		String query = "insert into Register values('" + U_id + "','"
				+ Password + "','" + F_name + "','" + L_name + "','" + Email
				+ "','+0')";

		System.out.println(query);

		try {
			int a = statement.executeUpdate(query);
			if (a == 1) {
				
				System.out.println("Register Successfully.");
				response.sendRedirect("SuccessfullRegister.jsp");
				
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
